<?php
function sendMail($email,$subject,$msg_body) {

    include(site_path.'inc/phpmailer/class.phpmailer.php');
    global $reg;

    $config = $reg->get('config');
    $db = $reg->get('db');

    $mail = new PHPMailer();
    $mail->SMTPAuth = true;

    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->Host     = $config['mail']['smtp']; // SMTP server

    $mail->From     = $config['mail']['email'];
    $mail->AddAddress($email);

    $mail->Host = $config['mail']['smtp'];
    $mail->Username = $config['mail']['user'];
    $mail->Password = $config['mail']['pass'];

    $mail->IsHTML(true);
    $mail->Subject  = $subject;
    $mail->MsgHTML($msg_body);

    if(!$mail->Send()) {
        return 'Error sending activation mail !';
    }
}

function genRndString($len) {
    $r_string = '';
    $str = 'asdfghjklpoiuy!><trelwqz,mnbvcxz!@#$%&()^1!092436[]-+';
    for($i=1;$i<=$len;$i++) {
        $r_string .= $str[rand(1,49)];
    }
    return $r_string;
}

?>
